package model.utils;

import java.sql.Connection;
import java.sql.SQLException;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.hibernate.Session;
import org.hibernate.jdbc.Work;


@Stateless
public class JpaUtil {

	@PersistenceContext(unitName = "selectPC")
    private EntityManager em;

    public EntityManager getEntityManager() {
        return em;
    }
    
    public void getConnection()
    {
    	
    	Session hibernateSession =	getEntityManager().unwrap(Session.class);
    	final Connection myconnection ;
    	hibernateSession.doWork(
    		    new Work() {
    		        public void execute(Connection connection) throws SQLException 
    		        { 
    		        	//connection ;
    		        	System.out.println("hehewkejkjsdsd");
    		        System.out.println("connectionautocommit = " + connection.getAutoCommit());
    		        }
    		    }
    		);
    	
    }
	
	//Session hibernateSession = entityManager.unwrap(Session.class);
//	Connection jdbcConnection = hibernateSession.connection(); 
	
	
	
}
